﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DataImport.cs" company="Concept Architecture">
//   (c) 2010 Muhammad Umer Farooq
// </copyright>
// <summary>
//   Defines the DataImport type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Hisaab.Windows.Client
{
    using System;
    using System.Collections.Generic;
    using System.IO;
    using Business.Interfaces;
    using LINQtoCSV;

    using Microsoft.Practices.ServiceLocation;

    using Model;
    using Account = Business.Entities.Account;
    using Transaction = Business.Entities.Transaction;

    /// <summary>
    /// Defines the <seealso cref="Hisaab.Windows.Client.DataImport"/> type.
    /// </summary>
    internal class DataImport
    {
        /// <summary>
        /// Gets the account manager.
        /// </summary>
        public IAccountManager AccountManager
        {
            get
            {
                return ServiceLocator.Current.GetInstance<IAccountManager>();
            }
        }

        /// <summary>
        /// Gets the transaction manager.
        /// </summary>
        public ITransactionManager TransactionManager
        {
            get
            {
                return ServiceLocator.Current.GetInstance<ITransactionManager>();
            }
        }

        /// <summary>
        /// Imports the CSV data.
        /// </summary>
        /// <param name="directory">The directory.</param>
        public void ImportCsvData(string directory)
        {
            var inputFileDescription = new CsvFileDescription { SeparatorChar = ',', FirstLineHasColumnNames = true };

            var accounts = new Dictionary<string, int>();
            var natwestSav = new Dictionary<int, int>();
            var natwestCurr = new Dictionary<int, int>();
            var hsbcSav = new Dictionary<int, int>();
            var hsbcJSav = new Dictionary<int, int>();
            var hsbcCurr = new Dictionary<int, int>();
            var hsbcJCurr = new Dictionary<int, int>();

            var csvContext = new CsvContext();

            int accId = 0;
            var natwestSavData = csvContext.Read<NatwestData>(Path.Combine(directory, "natwest saving.csv"), inputFileDescription);
            accId = AccountManager.Add(new Account { Name = "Natwest Saving", AccountType = (int)AccountTypes.BankAccount });
            accounts.Add("Natwest Saving", accId);
            foreach (var data in natwestSavData)
            {
                var transaction = data.GetTransaction(accId);
                var transId = TransactionManager.Add(transaction);
                natwestSav.Add(data.Id, transId);
            }

            var natwestCurrData = csvContext.Read<NatwestData>(Path.Combine(directory, "natwest current.csv"), inputFileDescription);
            accId = AccountManager.Add(new Account { Name = "Natwest Current", AccountType = (int)AccountTypes.BankAccount });
            accounts.Add("Natwest Current", accId);
            foreach (var data in natwestCurrData)
            {
                var transaction = data.GetTransaction(accId);
                var transId = TransactionManager.Add(transaction);
                natwestCurr.Add(data.Id, transId);
            }

            var hsbcSavData = csvContext.Read<HsbcData>(Path.Combine(directory, "hsbc saving.csv"), inputFileDescription);
            accId = AccountManager.Add(new Account { Name = "HSBC Saving", AccountType = (int)AccountTypes.BankAccount });
            accounts.Add("HSBC Saving", accId);
            foreach (var data in hsbcSavData)
            {
                var transaction = data.GetTransaction(accId);
                var transId = TransactionManager.Add(transaction);
                hsbcSav.Add(data.Id, transId);
            }

            var hsbcCurrData = csvContext.Read<HsbcData>(Path.Combine(directory, "HSBC current.csv"), inputFileDescription);
            accId = AccountManager.Add(new Account { Name = "HSBC Current", AccountType = (int)AccountTypes.BankAccount });
            accounts.Add("HSBC Current", accId);
            foreach (var data in hsbcCurrData)
            {
                var transaction = data.GetTransaction(accId);
                var transId = TransactionManager.Add(transaction);
                hsbcCurr.Add(data.Id, transId);
            }

            var hsbcJSavData = csvContext.Read<HsbcData>(Path.Combine(directory, "hsbc joint saving.csv"), inputFileDescription);
            accId = AccountManager.Add(new Account { Name = "HSBC Joint Saving", AccountType = (int)AccountTypes.BankAccount });
            accounts.Add("HSBC Joint Saving", accId);
            foreach (var data in hsbcJSavData)
            {
                var transaction = data.GetTransaction(accId);
                var transId = TransactionManager.Add(transaction);
                hsbcJSav.Add(data.Id, transId);
            }

            var hsbcJCurrData = csvContext.Read<HsbcData>(Path.Combine(directory, "hsbc joint current.csv"), inputFileDescription);
            accId = AccountManager.Add(new Account { Name = "HSBC Joint Current", AccountType = (int)AccountTypes.BankAccount });
            accounts.Add("HSBC Joint Current", accId);
            foreach (var data in hsbcJCurrData)
            {
                var transaction = data.GetTransaction(accId);
                var transId = TransactionManager.Add(transaction);
                hsbcJCurr.Add(data.Id, transId);
            }

            accId = AccountManager.Add(new Account { Name = "Barclays", AccountType = (int)AccountTypes.BankAccount });
            accounts.Add("Barclays", accId);

            accId = AccountManager.Add(new Account { Name = "HSBC Credit Card", AccountType = (int)AccountTypes.CreditCard });
            accounts.Add("HSBC Credit Card", accId);

            /*var amazonData = csvContext.Read<AmazonData>(Path.Combine(directory, "Amazon.csv"), inputFileDescription);
            accId = AccountManager.Add(new Account { Name = "Amazon", AccountType = (int)AccountTypes.OnlineAccount });
            accounts.Add("Amazon", accId);
            foreach (var data in amazonData)
            {
                var transaction = data.GetTransaction(accId);
                TransactionManager.Add(transaction);
            }

            var paypalData = csvContext.Read<PaypalData>(Path.Combine(directory, "paypal.csv"), inputFileDescription);
            accId = AccountManager.Add(new Account { Name = "Paypal", AccountType = (int)AccountTypes.OnlineAccount });
            accounts.Add("Paypal", accId);
            foreach (var data in paypalData)
            {
                var transaction = data.GetTransaction(accId);
                TransactionManager.Add(transaction);
            }

            var ebayData = csvContext.Read<EbayData>(Path.Combine(directory, "ebay.csv"), inputFileDescription);
            accId = AccountManager.Add(new Account { Name = "eBay", AccountType = (int)AccountTypes.OnlineAccount });
            accounts.Add("eBay", accId);
            foreach (var data in ebayData)
            {
                var transaction = data.GetTransaction(accId);
                TransactionManager.Add(transaction);
            }*/

            foreach (var data in natwestSavData)
            {
                if (data.ReferenceColumn.HasValue)
                {
                    int thisTransactionId = natwestSav[data.Id];
                    int otherTransactionId = natwestCurr[data.ReferenceColumn.Value];
                    TransactionManager.RelateTransactions(thisTransactionId, otherTransactionId);
                }
            }

            foreach (var data in natwestCurrData)
            {
                if (data.ReferenceColumn.HasValue)
                {
                    int thisTransactionId = natwestCurr[data.Id];
                    int otherTransactionId = 0;
                    switch (data.OtherAccount.Trim().ToLower())
                    {
                        case "natwest current":
                            otherTransactionId = natwestCurr[data.ReferenceColumn.Value];
                            break;
                        case "natwest saving":
                            otherTransactionId = natwestSav[data.ReferenceColumn.Value];
                            break;
                        case "hsbc current":
                            otherTransactionId = hsbcCurr[data.ReferenceColumn.Value];
                            break;
                        case "hsbc joint current":
                            otherTransactionId = hsbcJCurr[data.ReferenceColumn.Value];
                            break;
                        case "hsbc saving":
                            otherTransactionId = hsbcSav[data.ReferenceColumn.Value];
                            break;
                        case "hsbc joint saving":
                            otherTransactionId = hsbcJSav[data.ReferenceColumn.Value];
                            break;
                        default:
                            continue;
                    }

                    TransactionManager.RelateTransactions(thisTransactionId, otherTransactionId);
                }
            }

            foreach (var data in hsbcSavData)
            {
                if (data.ReferenceColumn.HasValue)
                {
                    int thisTransactionId = hsbcSav[data.Id];
                    int otherTransactionId = 0;
                    switch (data.OtherAccount.Trim().ToLower())
                    {
                        case "natwest current":
                            otherTransactionId = natwestCurr[data.ReferenceColumn.Value];
                            break;
                        case "natwest saving":
                            otherTransactionId = natwestSav[data.ReferenceColumn.Value];
                            break;
                        case "hsbc current":
                            otherTransactionId = hsbcCurr[data.ReferenceColumn.Value];
                            break;
                        case "hsbc joint current":
                            otherTransactionId = hsbcJCurr[data.ReferenceColumn.Value];
                            break;
                        case "hsbc saving":
                            otherTransactionId = hsbcSav[data.ReferenceColumn.Value];
                            break;
                        case "hsbc joint saving":
                            otherTransactionId = hsbcJSav[data.ReferenceColumn.Value];
                            break;
                        default:
                            continue;
                    }

                    TransactionManager.RelateTransactions(thisTransactionId, otherTransactionId);
                }
            }

            foreach (var data in hsbcCurrData)
            {
                if (data.ReferenceColumn.HasValue)
                {
                    int thisTransactionId = hsbcCurr[data.Id];
                    int otherTransactionId = 0;
                    switch (data.OtherAccount.Trim().ToLower())
                    {
                        case "natwest current":
                            otherTransactionId = natwestCurr[data.ReferenceColumn.Value];
                            break;
                        case "natwest saving":
                            otherTransactionId = natwestSav[data.ReferenceColumn.Value];
                            break;
                        case "hsbc current":
                            otherTransactionId = hsbcCurr[data.ReferenceColumn.Value];
                            break;
                        case "hsbc joint current":
                            otherTransactionId = hsbcJCurr[data.ReferenceColumn.Value];
                            break;
                        case "hsbc saving":
                            otherTransactionId = hsbcSav[data.ReferenceColumn.Value];
                            break;
                        case "hsbc joint saving":
                            otherTransactionId = hsbcJSav[data.ReferenceColumn.Value];
                            break;
                        default:
                            continue;
                    }

                    TransactionManager.RelateTransactions(thisTransactionId, otherTransactionId);
                }
            }

            foreach (var data in hsbcJSavData)
            {
                if (data.ReferenceColumn.HasValue)
                {
                    int thisTransactionId = hsbcJSav[data.Id];
                    int otherTransactionId = 0;
                    switch (data.OtherAccount.Trim().ToLower())
                    {
                        case "natwest current":
                            otherTransactionId = natwestCurr[data.ReferenceColumn.Value];
                            break;
                        case "natwest saving":
                            otherTransactionId = natwestSav[data.ReferenceColumn.Value];
                            break;
                        case "hsbc current":
                            otherTransactionId = hsbcCurr[data.ReferenceColumn.Value];
                            break;
                        case "hsbc joint current":
                            otherTransactionId = hsbcJCurr[data.ReferenceColumn.Value];
                            break;
                        case "hsbc saving":
                            otherTransactionId = hsbcSav[data.ReferenceColumn.Value];
                            break;
                        case "hsbc joint saving":
                            otherTransactionId = hsbcJSav[data.ReferenceColumn.Value];
                            break;
                        default:
                            continue;
                    }

                    TransactionManager.RelateTransactions(thisTransactionId, otherTransactionId);
                }
            }

            foreach (var data in hsbcJCurrData)
            {
                if (data.ReferenceColumn.HasValue)
                {
                    int thisTransactionId = hsbcJCurr[data.Id];
                    int otherTransactionId = 0;
                    switch (data.OtherAccount.Trim().ToLower())
                    {
                        case "natwest current":
                            otherTransactionId = natwestCurr[data.ReferenceColumn.Value];
                            break;
                        case "natwest saving":
                            otherTransactionId = natwestSav[data.ReferenceColumn.Value];
                            break;
                        case "hsbc current":
                            otherTransactionId = hsbcCurr[data.ReferenceColumn.Value];
                            break;
                        case "hsbc joint current":
                            otherTransactionId = hsbcJCurr[data.ReferenceColumn.Value];
                            break;
                        case "hsbc saving":
                            otherTransactionId = hsbcSav[data.ReferenceColumn.Value];
                            break;
                        case "hsbc joint saving":
                            otherTransactionId = hsbcJSav[data.ReferenceColumn.Value];
                            break;
                        default:
                            continue;
                    }

                    TransactionManager.RelateTransactions(thisTransactionId, otherTransactionId);
                }
            }
        }

        /// <summary>
        /// Defines the <seealso cref="Hisaab.Windows.Client.DataImport.AmazonData"/> type.
        /// </summary>
        private class AmazonData
        {
            /// <summary>
            /// Gets or sets the ID.
            /// </summary>
            /// <value>
            /// The Identifier
            /// </value>
            [CsvColumn(Name = "ID", FieldIndex = 1)]
            public int Id { get; set; }

            /// <summary>
            /// Gets or sets the date.
            /// </summary>
            /// <value>
            /// The date of transaction
            /// </value>
            [CsvColumn(Name = "Date", FieldIndex = 2, OutputFormat = "dd/MM/yyyy")]
            public DateTime Date { get; set; }

            /// <summary>
            /// Gets or sets the description.
            /// </summary>
            /// <value>
            /// The description.
            /// </value>
            [CsvColumn(Name = "Description", FieldIndex = 3)]
            public string Description { get; set; }

            /// <summary>
            /// Gets or sets the amount.
            /// </summary>
            /// <value>
            /// The amount.
            /// </value>
            [CsvColumn(Name = "Amount", FieldIndex = 4)]
            public decimal Amount { get; set; }

            /// <summary>
            /// Gets or sets the balanced.
            /// </summary>
            /// <value>
            /// The balanced.
            /// </value>
            [CsvColumn(Name = "Balanced", FieldIndex = 5)]
            public object Balanced { get; set; }

            /// <summary>
            /// Gets the transaction.
            /// </summary>
            /// <param name="accountId">The account id.</param>
            /// <returns>Converted Trabsactuib</returns>
            public Transaction GetTransaction(int accountId)
            {
                return new Transaction
                           {
                               Account = accountId,
                               Date = Date,
                               Title = Description,
                               Amount = Amount
                           };
            }
        }

        /// <summary>
        /// Defines the <seealso cref="Hisaab.Windows.Client.DataImport.PaypalData"/> type.
        /// </summary>
        private class PaypalData
        {
            // ID,Date, Name, Type, Currency, Amount, Balance,Balanced

            /// <summary>
            /// Gets or sets the ID.
            /// </summary>
            /// <value>
            /// The Identifier
            /// </value>
            [CsvColumn(Name = "ID", FieldIndex = 1)]
            public int Id { get; set; }

            /// <summary>
            /// Gets or sets the date.
            /// </summary>
            /// <value>
            /// The date of transaction
            /// </value>
            [CsvColumn(Name = "Date", FieldIndex = 2, OutputFormat = "dd/MM/yyyy")]
            public DateTime Date { get; set; }

            /// <summary>
            /// Gets or sets the description.
            /// </summary>
            /// <value>
            /// The description.
            /// </value>
            [CsvColumn(Name = "Name", FieldIndex = 3)]
            public string Name { get; set; }

            /// <summary>
            /// Gets or sets the amount.
            /// </summary>
            /// <value>
            /// The amount.
            /// </value>
            [CsvColumn(Name = "Type", FieldIndex = 4)]
            public string Type { get; set; }

            /// <summary>
            /// Gets or sets the balanced.
            /// </summary>
            /// <value>
            /// The balanced.
            /// </value>
            [CsvColumn(Name = "Currency", FieldIndex = 5)]
            public string Currency { get; set; }

            /// <summary>
            /// Gets or sets the amount.
            /// </summary>
            /// <value>
            /// The amount.
            /// </value>
            [CsvColumn(Name = "Amount", FieldIndex = 6)]
            public decimal Amount { get; set; }

            /// <summary>
            /// Gets or sets the amount.
            /// </summary>
            /// <value>
            /// The amount.
            /// </value>
            [CsvColumn(Name = "Balance", FieldIndex = 7)]
            public decimal Balance { get; set; }

            /// <summary>
            /// Gets or sets the balanced.
            /// </summary>
            /// <value>
            /// The balanced.
            /// </value>
            [CsvColumn(Name = "Balanced", FieldIndex = 8)]
            public object Balanced { get; set; }

            /// <summary>
            /// Gets the transaction.
            /// </summary>
            /// <param name="accountId">The account id.</param>
            /// <returns>Converted Trabsactuib</returns>
            public Transaction GetTransaction(int accountId)
            {
                return new Transaction
                {
                    Account = accountId,
                    Date = Date,
                    Title = Name,
                    Amount = Amount
                };
            }
        }

        /// <summary>
        /// Defines the <seealso cref="Hisaab.Windows.Client.DataImport.EbayData"/> type.
        /// </summary>
        private class EbayData
        {
            /// <summary>
            /// Gets or sets the ID.
            /// </summary>
            /// <value>
            /// The Identifier
            /// </value>
            [CsvColumn(Name = "ID", FieldIndex = 1)]
            public int Id { get; set; }

            /// <summary>
            /// Gets or sets the date.
            /// </summary>
            /// <value>
            /// The date of transaction
            /// </value>
            [CsvColumn(Name = "Date", FieldIndex = 2, OutputFormat = "dd/MM/yyyy")]
            public DateTime Date { get; set; }

            /// <summary>
            /// Gets or sets the description.
            /// </summary>
            /// <value>
            /// The description.
            /// </value>
            [CsvColumn(Name = "Name", FieldIndex = 3)]
            public string Name { get; set; }

            /// <summary>
            /// Gets or sets the amount.
            /// </summary>
            /// <value>
            /// The amount.
            /// </value>
            [CsvColumn(Name = "Amount", FieldIndex = 4)]
            public decimal Amount { get; set; }

            /// <summary>
            /// Gets or sets the balanced.
            /// </summary>
            /// <value>
            /// The balanced.
            /// </value>
            [CsvColumn(Name = "Balanced", FieldIndex = 5)]
            public decimal Balanced { get; set; }

            /// <summary>
            /// Gets the transaction.
            /// </summary>
            /// <param name="accountId">The account id.</param>
            /// <returns>Converted Trabsactuib</returns>
            public Transaction GetTransaction(int accountId)
            {
                return new Transaction
                {
                    Account = accountId,
                    Date = Date,
                    Title = Name,
                    Amount = Amount
                };
            }
        }

        /// <summary>
        /// Defines the <seealso cref="Hisaab.Windows.Client.DataImport.NatwestData"/> type.
        /// </summary>
        private class NatwestData
        {
            // ID,Date, Type, Description,  Value ,  Balance , Account Name, Account Number,Title,Other Account,Reference Column

            /// <summary>
            /// Gets or sets the ID.
            /// </summary>
            /// <value>
            /// The Identifier
            /// </value>
            [CsvColumn(Name = "ID", FieldIndex = 1)]
            public int Id { get; set; }

            /// <summary>
            /// Gets or sets the date.
            /// </summary>
            /// <value>
            /// The date of transaction
            /// </value>
            [CsvColumn(Name = "Date", FieldIndex = 2, OutputFormat = "dd/MM/yyyy")]
            public DateTime Date { get; set; }

            /// <summary>
            /// Gets or sets the description.
            /// </summary>
            /// <value>
            /// The description.
            /// </value>
            [CsvColumn(Name = "Type", FieldIndex = 3)]
            public string Type { get; set; }

            /// <summary>
            /// Gets or sets the description.
            /// </summary>
            /// <value>
            /// The description.
            /// </value>
            [CsvColumn(Name = "Description", FieldIndex = 4)]
            public string Description { get; set; }

            /// <summary>
            /// Gets or sets the amount.
            /// </summary>
            /// <value>
            /// The amount.
            /// </value>
            [CsvColumn(Name = "Value", FieldIndex = 5)]
            public decimal Value { get; set; }

            /// <summary>
            /// Gets or sets the amount.
            /// </summary>
            /// <value>
            /// The amount.
            /// </value>
            [CsvColumn(Name = "Balance", FieldIndex = 6)]
            public decimal Balance { get; set; }

            /// <summary>
            /// Gets or sets the amount.
            /// </summary>
            /// <value>
            /// The amount.
            /// </value>
            [CsvColumn(Name = "Account Name", FieldIndex = 7)]
            public string AccountName { get; set; }

            /// <summary>
            /// Gets or sets the amount.
            /// </summary>
            /// <value>
            /// The amount.
            /// </value>
            [CsvColumn(Name = "Account Number", FieldIndex = 8)]
            public string AccountNumber { get; set; }

            /// <summary>
            /// Gets or sets the amount.
            /// </summary>
            /// <value>
            /// The amount.
            /// </value>
            [CsvColumn(Name = "Title", FieldIndex = 9)]
            public string Title { get; set; }

            /// <summary>
            /// Gets or sets the amount.
            /// </summary>
            /// <value>
            /// The amount.
            /// </value>
            [CsvColumn(Name = "Other Account", FieldIndex = 10)]
            public string OtherAccount { get; set; }

            /// <summary>
            /// Gets or sets the balanced.
            /// </summary>
            /// <value>
            /// The balanced.
            /// </value>
            [CsvColumn(Name = "Reference Column", FieldIndex = 11)]
            public int? ReferenceColumn { get; set; }

            /// <summary>
            /// Gets the transaction.
            /// </summary>
            /// <param name="accountId">The account id.</param>
            /// <returns>Transaction converted</returns>
            public Business.Entities.Transaction GetTransaction(int accountId)
            {
                return new Business.Entities.Transaction
                {
                    Account = accountId,
                    Date = Date,
                    Title = string.IsNullOrWhiteSpace(Title) ? "Transaction" : Title,
                    Details = Description,
                    Amount = Math.Abs(Value),
                    TransactionType = Value < 0 ? Business.Entities.TransactionTypes.Expanse : Business.Entities.TransactionTypes.Income,
                    IsTransferTransaction = false
                };
            }
        }

        /// <summary>
        /// Defines the <seealso cref="Hisaab.Windows.Client.DataImport.HsbcData"/> type.
        /// </summary>
        private class HsbcData
        {
            // ID,Date ,Type ,Description , Amount , Balance (£) ,Title,Other Account,Reference Column,

            /// <summary>
            /// Gets or sets the ID.
            /// </summary>
            /// <value>
            /// The Identifier
            /// </value>
            [CsvColumn(Name = "ID", FieldIndex = 1)]
            public int Id { get; set; }

            /// <summary>
            /// Gets or sets the date.
            /// </summary>
            /// <value>
            /// The date of transaction
            /// </value>
            [CsvColumn(Name = "Date", FieldIndex = 2, OutputFormat = "dd/MM/yyyy")]
            public DateTime Date { get; set; }

            /// <summary>
            /// Gets or sets the description.
            /// </summary>
            /// <value>
            /// The description.
            /// </value>
            [CsvColumn(Name = "Type", FieldIndex = 3)]
            public string Type { get; set; }

            /// <summary>
            /// Gets or sets the description.
            /// </summary>
            /// <value>
            /// The description.
            /// </value>
            [CsvColumn(Name = "Description", FieldIndex = 4)]
            public string Description { get; set; }

            /// <summary>
            /// Gets or sets the amount.
            /// </summary>
            /// <value>
            /// The amount.
            /// </value>
            [CsvColumn(Name = "Amount", FieldIndex = 5)]
            public decimal Amount { get; set; }

            /// <summary>
            /// Gets or sets the amount.
            /// </summary>
            /// <value>
            /// The amount.
            /// </value>
            [CsvColumn(Name = "Balance", FieldIndex = 6)]
            public decimal Balance { get; set; }

            /// <summary>
            /// Gets or sets the amount.
            /// </summary>
            /// <value>
            /// The amount.
            /// </value>
            [CsvColumn(Name = "Title", FieldIndex = 7)]
            public string Title { get; set; }

            /// <summary>
            /// Gets or sets the amount.
            /// </summary>
            /// <value>
            /// The amount.
            /// </value>
            [CsvColumn(Name = "Other Account", FieldIndex = 8)]
            public string OtherAccount { get; set; }

            /// <summary>
            /// Gets or sets the balanced.
            /// </summary>
            /// <value>
            /// The balanced.
            /// </value>
            [CsvColumn(Name = "Reference Column", FieldIndex = 9)]
            public int? ReferenceColumn { get; set; }

            /// <summary>
            /// Gets the transaction.
            /// </summary>
            /// <param name="accountId">The account id.</param>
            /// <returns>Transaction converted</returns>
            public Business.Entities.Transaction GetTransaction(int accountId)
            {
                return new Business.Entities.Transaction
                {
                    Account = accountId,
                    Date = Date,
                    Title = string.IsNullOrWhiteSpace(Title) ? "Transaction" : Title,
                    Details = Description,
                    Amount = Math.Abs(Amount),
                    TransactionType = Amount < 0 ? Business.Entities.TransactionTypes.Expanse : Business.Entities.TransactionTypes.Income
                };
            }
        }
    }
}